library(gplots)


# Selective sweeps

ress <- read.csv("hit.log.csv",header=FALSE)

selcoefflab <- c("s=0.001","s=0.01","s=0.1","s=0.5","s=1","s=2")
selmulab <- c("m=10^-5","m=10^-6","m=10^-7","m=10^-8")

pdf("number.of.hits.pdf",width=6, height=6)

for(selcoeff in 1:6){
for(selmu in 1:4){

res <- ress[((selcoeff-1)*20+(selmu-1)*5+1):((selcoeff-1)*20+(selmu-1)*5+5),]

colnames(res) <- c("r=0","r=0.25","r=0.5","r=0.75","r=1")
rownames(res) <- c("1 hit","2 hits","3 hits","4 hits", "5 hits")

res <- as.matrix(res)
mp <- barplot2(res/9, beside = FALSE,
        col = gray(1-(0:4/4)),
	ylim = c(0,1),        
        main = paste("Selective coefficient",selcoefflab[selcoeff],"Selective mutation rate",selmulab[selmu]), font.main = 4,
        plot.grid = TRUE)
legend(24,1,legend=rownames(res),fill=gray(1-(0:4/4)))
mtext(side=2, text="Average percentage of reproductive hits at end of run",line=2)
mtext(side=1, text="Crypt division probability (r)",line=2)
}
}

dev.off()


